package cn.restcloud.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import cn.restcloud.springboot.listener.RestCloudEnvPreparedEventListener;

@ComponentScan(basePackages = "cn.restcloud")
@SpringBootApplication
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class,MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})

public class SpringbootApplication extends SpringBootServletInitializer{

	/**
	 * jar包启动模式
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("Version:V4.5 dev start...");
		SpringApplication springApplication =new SpringApplication(SpringbootApplication.class);
	    springApplication.addListeners(new RestCloudEnvPreparedEventListener());
	    springApplication.run(args);
	}
	
	
	/**
	 * war包启动模式
	 */
	@Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		System.out.println("Version:V4.5 start...");
		builder.application().addListeners(new RestCloudEnvPreparedEventListener());
        return builder.sources(SpringbootApplication.class);
    }
	  
}
